/**
 * 
 */
package com.hand.cloud.b2b.daos.impl;

import de.hybris.bootstrap.annotations.IntegrationTest;
import de.hybris.platform.basecommerce.model.site.BaseSiteModel;
import de.hybris.platform.core.model.c2l.LanguageModel;
import de.hybris.platform.core.model.order.OrderModel;
import de.hybris.platform.core.model.order.delivery.DeliveryModeModel;
import de.hybris.platform.jalo.c2l.Language;
import de.hybris.platform.order.DeliveryModeService;
import de.hybris.platform.servicelayer.ServicelayerTransactionalTest;
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.site.BaseSiteService;
import de.hybris.platform.store.BaseStoreModel;
import de.hybris.platform.store.services.BaseStoreService;

import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.junit.Test;

import com.hand.cloud.b2b.daos.OrderDAO;


/**
 * @author StephenWang
 * @time Aug 6, 2014 3:57:59 PM
 * 
 */
@IntegrationTest
public class DefaultCustomerDAOTest extends ServicelayerTransactionalTest
{

	//	@Resource
	//	private CustomerDAO customerDAO;
	//
	//	private CustomerModel customer;

	@Resource
	private BaseSiteService baseSiteService;

	@Resource
	private BaseStoreService baseStoreService;

	@Resource
	private FlexibleSearchService flexibleSearchService;

	@Resource
	private DeliveryModeService deliveryModeService;

	@Resource
	private OrderDAO orderDAO;

	@Test
	public void testCustomer()
	{

		LanguageModel language = orderDAO.getLanguageByCode("zh");
		System.out.println(language.getPk());

		//		customer = customerDAO.createCustomer();
		//		//customer = customerDAO.getCustomerByUid("ppetersonson"); // customerId:K2006-C0001
		//		Assert.notNull(customer);

//		Collection<BaseSiteModel> baseSites = baseSiteService.getAllBaseSites();
//
//		for (BaseSiteModel baseSite : baseSites)
//		{
//			System.out.println(">>>>>>>>>>>>>>>>>>baseSite:" + baseSite.getUid());
//			//		>>>>>>>>>>>>>>>>>>baseSite:powertools
//		}
//
//		Collection<BaseStoreModel> baseStores = baseStoreService.getAllBaseStores();
//
//		for (BaseStoreModel baseStore : baseStores)
//		{
//			System.out.println(">>>>>>>>>>>>>>>>>>baseStore:" + baseStore.getUid());
//			//		>>>>>>>>>>>>>>>>>>baseStore:powertools
//		}
//
//		Collection<DeliveryModeModel> deliveryModes = deliveryModeService.getAllDeliveryModes();
//
//		for (DeliveryModeModel deliveryMode : deliveryModes)
//		{
//			System.out.println(">>>>>>>>>>>>>>>>>>deliveryMode:" + deliveryMode.getCode());
//			//		>>>>>>>>>>>>>>>>>>deliveryMode:free-standard-shipping
//			//		>>>>>>>>>>>>>>>>>>deliveryMode:premium-gross
//			//		>>>>>>>>>>>>>>>>>>deliveryMode:premium-net
//			//		>>>>>>>>>>>>>>>>>>deliveryMode:standard-gross
//			//		>>>>>>>>>>>>>>>>>>deliveryMode:standard-net
//		}


	}

	//	@Test
	public void testDate()
	{
		// We use this to format date.
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		// Using current date for example.
		String dateStr = format.format(new Date());

		// Searching Order for example.
		StringBuffer queryStr = new StringBuffer("SELECT {pk} FROM {Order} WHERE {modifiedtime} <= '" + dateStr + "'");

		// Setting the search query.
		FlexibleSearchQuery query = new FlexibleSearchQuery(queryStr.toString());

		// Getting results.
		List<Object> result = flexibleSearchService.search(query).getResult();

		// Iterating all the records.
		for (Object obj : result)
		{
			OrderModel order = (OrderModel) obj;
			System.out.println("order_code:" + order.getCode());
		}
	}
}
